package cn.wps.moffice.main.thirdinfo; import android.app.IntentService; import android.content.Intent; import android.os.Environment; import android.text.TextUtils; import android.text.format.Formatter; import android.util.Log; import cn.wps.moffice.OfficeApp; import cn.wps.moffice.define.VersionManager; import com.mopub.nativeads.KS2SEventNative; import defpackage.huc; import java.io.File; import java.util.HashMap; import org.json.JSONException; import org.json.JSONObject; import org.scribe.model.OAuthConstants; public class ThirdInfoPackService extends IntentService { volatile boolean iOB; public ThirdInfoPackService() { super("ThirdInfoPackService"); } private long al(File file) { long j; if (file.isFile()) { j = file.length(); } else { File[] listFiles = file.listFiles(); j = 0; if (listFiles != null) { int length = listFiles.length; int i = 0; boolean z = false | false; while (i < length) { long al = al(listFiles[i]) + j; i++; j = al; } } } return j; } /* JADX INFO: finally extract failed */ private synchronized void clf() { try { huc.a cld = huc.cld(); String str = cld.name; String str2 = cld.path; if (huc.a(cld)) { if (Environment.getExternalStorageDirectory() == null) { kC("getExternalStorageDirectory is null"); } else { String absolutePath = Environment.getExternalStorageDirectory().getAbsolutePath(); String str3 = huc.iOy; try { String str4 = absolutePath + str2; kC("targetFilePath is " + str4); File file = new File(str4); if (file.exists()) { long al = al(file); kC("targetFileLength is " + Formatter.formatFileSize(this, al)); if (al > 15728640 || al == 0) { fza.bJK().n("third_info_pack_last_upload_time", System.currentTimeMillis()); kC("targetFileLength is more than MAX_FILE_SIZE or is 0"); } else { File file2 = new File(str3); if (!file2.exists()) { file2.mkdirs(); } String str5 = str3 + File.separator + OfficeApp.arx().arG() + ".temp"; kC("zipTempFilePath is " + str5); File file3 = new File(str5); if (file3.exists()) { kC("zipTempFile exist, delete zipTempFile cache"); file3.delete(); } kC("start zip"); long currentTimeMillis = System.currentTimeMillis(); ehu.aP(str4, str5); kC("over zip, spend time : " + (System.currentTimeMillis() - currentTimeMillis)); String str6 = str3 + File.separator + OfficeApp.arx().arG(); kC("encryptFilePath is : " + str6); File file4 = new File(str6); if (!file4.exists()) { file4.createNewFile(); } kC("start encryptFile"); long currentTimeMillis2 = System.currentTimeMillis(); hub.dh(str5, str6); kC("over encryptFile, spend time : " + (System.currentTimeMillis() - currentTimeMillis2)); kC("delete zipTempFile"); file3.delete(); if (di(str, str6)) { fza.bJK().n("third_info_pack_last_upload_time", System.currentTimeMillis()); } kC("delete encryptFile"); file4.delete(); } } else { fza.bJK().n("third_info_pack_last_upload_time", System.currentTimeMillis()); kC("targetFilePath no exist"); } } catch (Throwable th) { if (VersionManager.aYO()) { th.printStackTrace(); } } } } } catch (Throwable th2) { throw th2; } } private boolean di(String str, String str2) { boolean z; if (new File(str2).exists()) { HashMap hashMap = new HashMap(); hashMap.put("name", str); HashMap hashMap2 = new HashMap(); hashMap2.put(KS2SEventNative.SCHEME_FILE, str2); kC("start upload"); long currentTimeMillis = System.currentTimeMillis(); String a = ehz.a("https://moapi.wps.cn/zip_upload/upload", hashMap, hashMap2); kC("over upload, spend time : " + (System.currentTimeMillis() - currentTimeMillis)); kC("upload result:" + a); if (!TextUtils.isEmpty(a)) { try { if (new JSONObject(a).optInt(OAuthConstants.CODE, -1) == 0) { kC("upload success"); z = true; return z; } } catch (JSONException e) { kC("upload result json error"); } } } z = false; return z; } private static void kC(String str) { if (VersionManager.aYO()) { Log.i("ThirdInfoPackService", str); } } /* JADX INFO: finally extract failed */ /* access modifiers changed from: protected */ public void onHandleIntent(Intent intent) { if (!this.iOB) { try { kC("onHandleIntent do can check"); if (lwd.isWifiConnected(this)) { huc.clearCache(); this.iOB = true; clf(); } else { kC("onHandleIntent>>>no wifi"); } huc.clearCache(); } catch (Throwable th) { huc.clearCache(); throw th; } } } }